<template>
  <div class="left-bot">
    <dv-border-box-13>
      <Swiper :autoPlay="true" :showIndicator="false" interval="5500" duration="600">
        <Slide>
          <title-bar :data="{name: '资产'}"></title-bar>
          <div class="my-swiper my-swiper-3">
            <div class="item-box" v-for="(item, index) in items" :key="index">
              <dv-charts class="my-dv-charts" :option="item.option" />
              <div class="item-data">
                <div class="item-data-percent">{{item.percent}}</div>
                <div class="item-data-desc">{{item.desc}}</div>
              </div>
            </div>
          </div>
        </Slide>
        <Slide>
          <title-bar :data="{name: '负债'}"></title-bar>
          <dv-charts class="my-swiper-1" :option="option" />
          <dv-scroll-board class="my-swiper-2" :config="config" />
        </Slide>
      </Swiper>
    </dv-border-box-13>
  </div>
</template>
<script>
import { Swiper, Slide } from 'vue-swiper-component'
import { mapGetters } from 'vuex'
// import getRandom from '@/assets/js/getRandom'
export default {
  name: 'LeftBot',
  components: { Swiper, Slide },
  data () {
    return {
      items: [
        {
          percent: '80%',
          desc: '年化资产收益率',
          option: {
            series: [
              {
                type: 'gauge',
                startAngle: -Math.PI / 2,
                endAngle: Math.PI * 1.5,
                arcLineWidth: 10,
                data: [
                  { name: 'itemA', value: 80, gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
                ],
                axisLabel: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                pointer: {
                  show: false
                },
                dataItemStyle: {
                  lineCap: 'round'
                },
                details: {
                  show: false,
                  formatter: '{value}%',
                  style: {
                    fill: '#1ed3e5',
                    fontSize: 14
                  }
                }
              }
            ]
          }
        },
        {
          percent: '90%',
          desc: '年化资本收益率',
          option: {
            series: [
              {
                type: 'gauge',
                startAngle: -Math.PI / 2,
                endAngle: Math.PI * 1.5,
                arcLineWidth: 10,
                data: [
                  { name: 'itemA', value: 90, gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
                ],
                axisLabel: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                pointer: {
                  show: false
                },
                dataItemStyle: {
                  lineCap: 'round'
                },
                details: {
                  show: false,
                  formatter: '{value}%',
                  style: {
                    fill: '#1ed3e5',
                    fontSize: 14
                  }
                }
              }
            ]
          }
        },
        {
          percent: '70%',
          desc: '年化股本收益率',
          option: {
            series: [
              {
                type: 'gauge',
                startAngle: -Math.PI / 2,
                endAngle: Math.PI * 1.5,
                arcLineWidth: 10,
                data: [
                  { name: 'itemA', value: 70, gradient: ['#03c2fd', '#1ed3e5', '#2fded6'] }
                ],
                axisLabel: {
                  show: false
                },
                axisTick: {
                  show: false
                },
                pointer: {
                  show: false
                },
                dataItemStyle: {
                  lineCap: 'round'
                },
                details: {
                  show: false,
                  formatter: '{value}%',
                  style: {
                    fill: '#1ed3e5',
                    fontSize: 14
                  }
                }
              }
            ]
          }
        }
      ],
      config: {
        waitTime: 2000,
        header: ['存款结构', '金额(万元)', '占比'],
        align: ['left', 'left', 'left'],
        columnWidth: [100, 100, 80],
        data: [
          ['活期存款', '15,227.36', '40%'],
          ['定期存款', '23.234.05', '60%']
        ]
      },
      option: {
        series: [
          {
            type: 'pie',
            data: [
              { name: '定期存款', value: 60 },
              { name: '活期存款', value: 40 }
            ],
            radius: ['40%', '50%'],
            insideLabel: {
              show: true
            }
          }
        ]
      }
    }
  },
  computed: {
    ...mapGetters(['getCount'])
  },
  watch: {
    getCount () {
      // const num = getRandom(50, 100)
      // this.option = {
      //   series: [
      //     {
      //       type: 'pie',
      //       data: [
      //         { name: '定期存款', value: num },
      //         { name: '活期存款', value: 100 - num }
      //       ],
      //       radius: ['40%', '50%'],
      //       insideLabel: {
      //         show: true
      //       }
      //     }
      //   ]
      // }
    }
  }
}
</script>
<style lang="less">
  .left-bot {
    height: 500px;
    overflow: hidden;
    .my-swiper-1 {
      height: 250px !important;
      margin-top: 0 !important;
    }
    .my-swiper-2 {
      height: 150px !important;
      margin-top: 0 !important;
      padding: 0 20px;
    }
    .my-swiper-3 {
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      align-items: center;
    }
    .item-box {
      display: flex;
      align-items: center;
      width: 350px;
      height: 100px;
      background-size: cover !important;
      border-top-left-radius: 50px;
      border-bottom-left-radius: 50px;
      overflow: hidden;
      .my-dv-charts {
        height: 100px;
        width: 100px;
      }
      .item-data-percent {
        color: #fff;
        font-size: 24px;
      }
      .item-data {
        margin-left: 16px;
      }
    }
    .item-box:nth-child(1) {
      background: url('../../assets/img/zichang-bar.png');
    }
    .item-box:nth-child(2) {
      background: url('../../assets/img/ziben-bar.png');
    }
    .item-box:nth-child(3) {
      background: url('../../assets/img/guben-bar.png');
    }
    .icon {
      margin-top: 13px;
    }
    .row-item {
      height: 48px !important;
      line-height: 48px !important;
      background: rgba(255, 255, 255, 0.1) !important;
      color: #40FFE6;
      margin-top: 5px;
    }
    .header {
      background: none !important;
      color: #ccc;
    }
  }
</style>
